
/**
 * AppleIIGo
 * Disk 3.5" Interface Card class
 * (C) 2008 by Marc S. Ressl (mressl@umich.edu)
 * Released under the GPL
 */

#include "Apple35FloppyDiskDriveInterfaceCard.h"

char * apple35FloppyDiskDriveList[] = {
	"UniDisk35DiskDrive",
	"UniDisk35DiskDrive",
	"SmartPortDiskDrive",
	"SmartPortDiskDrive",
	0,
};

Apple35FloppyDiskDriveInterfaceCard::Apple35FloppyDiskDriveInterfaceCard(
	Motherboard * motherboard, char * slotDeviceName) :
IWM(motherboard, slotDeviceName) {
	connectDrives(apple35FloppyDiskDriveList);
}

void Apple35FloppyDiskDriveInterfaceCard::onMemoryRequested() {
	romMemoryOffset = motherboard->getMemory()->requestMemory(
		APPLE35FLOPPYDISKDRIVEINTERFACECARD_ROM_BYTENUM);
}

void Apple35FloppyDiskDriveInterfaceCard::onMemoryAllocated() {
	romMemory = motherboard->getMemory()->getMemory(romMemoryOffset);
	char * romImage = "Apple 3.5 Floppy Disk Drive Interface Card ROM.bin";
	motherboard->getResources()->readResource(romMemory,
		APPLE35FLOPPYDISKDRIVEINTERFACECARD_ROM_BYTENUM, romImage);
}

UINT8 Apple35FloppyDiskDriveInterfaceCard::readMemory(UINT16 address) {
	if ((address & 0xffe) == 0xffe)
		return timingGenerator->readFloatingBus();
	else
		return romMemory[address & 0xfff];
}
